package cn.myeasyai.util.result;


import cn.myeasyai.util.BusinessException;
import cn.myeasyai.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 整体异常处理
 * @author fushoujiang
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        return Result.resultFail(-1,e.getMessage());
    }
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result error(BusinessException e){
        return Result.resultFail(-1,e.getMessage());
    }

}